﻿je_meiji_restoration = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"

	is_shown_when_inactive = {
		exists = c:JAP
		c:JAP = ROOT
		NOT = { has_variable = meiji_restoration_complete }
		has_law = law_type:law_monarchy
	}

	possible = {
		ig:ig_landowners = {
			is_in_government = no
		}
	}

	immediate = {
		set_variable = {
			name = shogunate_var
			value = 0
		}
	}
	on_monthly_pulse = {
		effect = {
			if = {
				limit = {
					ig:ig_landowners = {
						is_powerful = no
						is_in_government = no
					}
					has_insurrectionary_interest_groups = no
					is_at_war = no
					owns_entire_state_region = STATE_KANTO
				}
				change_variable = {
					name = shogunate_var
					add = 1
				}
			}
		}
	}

	complete = {
		# If-else clause to avoid errors because of missing variable before JE activates
		trigger_if = {
			limit = { exists = var:shogunate_var }
			scope:journal_entry = { is_goal_complete = yes }
		}
		trigger_else = {
			custom_tooltip = je_meiji_restoration_goal
		}
		ig:ig_landowners = {
			is_powerful = no
			is_in_government = no
		}
		has_insurrectionary_interest_groups = no
		is_at_war = no
		owns_entire_state_region = STATE_KANTO
	}

	on_complete = {
		set_variable = meiji_restoration_complete
		trigger_event = {
			id = meiji.1
		}
	}

	current_value = {
		value = root.var:shogunate_var
	}

	goal_add_value = {
		value = 1
	}

	progressbar = yes


	weight = 10000
	should_be_pinned_by_default = yes
}


je_meiji_main = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	on_complete = {
		trigger_event = {
			id = meiji.2
		}
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = meiji.4
			10 = meiji.5
			10 = meiji.6
		}
	}

	current_value = {
		value = var:meiji_var
	}

	goal_add_value = {
		add = 3
	}

	progressbar = yes

	weight = 10000
	should_be_pinned_by_default = yes
}

je_meiji_economy = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"

	complete = {
		in_default = no
		any_scope_state = {
			filter = {
				is_incorporated = yes
			}
			any_scope_building = {
				is_building_type = building_urban_center
				level >= 5
			}
			has_building = building_railway
			percent > 0.7
		}
	}

	on_complete = {
		change_variable = {
			name = meiji_var
			add = 1
		}
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = meiji.7
			10 = meiji.8
		}
	}

	inheritable = no

	weight = 5000
}

je_meiji_army = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"

	complete = {
		NOT = { has_law = law_type:law_serfdom }
		ig:ig_armed_forces = {
			is_powerful = no
			is_in_government = no
		}
		has_technology_researched = napoleonic_warfare
		NOT = {
			any_scope_building = {
				is_building_type = building_barracks
				OR = {
					has_active_production_method = pm_irregular_infantry
					has_active_production_method = pm_no_artillery
					has_active_production_method = pm_cannon_artillery
				}
			}
		}
	}

	on_complete = {
		change_variable = {
			name = meiji_var
			add = 1
		}
		trigger_event = {
			id = meiji.3
		}
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = meiji.9
			10 = meiji.10
		}
	}

	inheritable = no

	weight = 5000
}

je_meiji_diplomacy = {
	icon = "gfx/interface/icons/event_icons/event_trade.dds"

	complete = {
		NOT = { has_law = law_type:law_isolationism }
		NOT = { has_law = law_type:law_traditionalism }
		NOT = { has_law = law_type:law_closed_borders }
		is_subject = no
	}

	on_complete = {
		change_variable = {
			name = meiji_var
			add = 1
		}
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = meiji.11
			10 = meiji.12
		}
	}

	weight = 10000
}
